package com.lilinling.yinzhi.order.web;

import com.lilinling.common.utils.JwtInfo;
import com.lilinling.common.utils.JwtUtils;
import com.lilinling.common.utils.R;
import com.lilinling.yinzhi.order.dao.OrderDao;
import com.lilinling.yinzhi.order.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@Api("订单页面接口")
@RestController
@RequestMapping("order/orderweb")
public class OrderWebController {
    @Autowired
    private OrderService orderService;

    @ApiOperation("下单")
    @PostMapping("/auth/submitOrder/{makerId}")
    public R submitOrder(@PathVariable Long makerId, HttpServletRequest request){
        JwtInfo jwtInfo = JwtUtils.getUserIdByJwtToken(request);
        Long orderId = orderService.submitOrder(makerId,jwtInfo);
        return R.ok().put("orderId",orderId);
    }

}
